package com.dream.utilservice.Controlller;

import com.dream.utilservice.anno.Testannotation;
import com.dream.utilservice.entity.SysFiled;
import com.dream.utilservice.mapper.SysFiledMapper;
import com.dream.utilservice.utils.PoiUtil;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.StringTokenizer;

@RestController
public class TestController {



    @Autowired
    SysFiledMapper mapper;
//    @Testannotation(testkey = "#id",testname = "weiwei",ifture = true)
//    @GetMapping("/test")
//    public void String(String id){
//        System.out.println("test success");
//    }
    @GetMapping("/test")
    public List<SysFiled> getlist(@RequestParam String menuid,@RequestParam String funcvalue, @RequestParam String inout, @RequestParam String layer) throws IOException {

        String filepath = "C:\\Users\\user\\Desktop\\获取表格内容文档.docx";
        List<SysFiled> list = PoiUtil.product2(filepath);

        for (SysFiled s: list) {

            List<String> stringList = mapper.getid(s.getField());
            if (stringList.size()>0){
                s.setId(stringList.get(0));
            }
            if (s.getIsNotNull().equals("Y")){
                s.setIsNotNull("1");
            }else if (s.getIsNotNull().equals("N")){
                s.setIsNotNull("0");
            }
            System.out.println("("+"'"+menuid+"'"+","+"'"+funcvalue+"'"+","+"'"+s.getId()+"'"+","+"'"+inout+"'"+","+"NULL"+","+"'"+s.getIsNotNull()+"'"+","+"'"+"1"+"'"+","+"'"+layer+"'"+")"+",");
        }
        return list;
    }
}
